home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / toolPropertyWindow1.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  9.5 KB  |  343 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. // This method brings up the basic framework of
  18. // the tool property sheet.
  19. //
  20. // All the individual property sheets place themselves
  21. // within this framework.
  22.  
  23. global proc toolPropertyWinSetCommon(string $toolName, string $icon) 
  24. {
  25.     print ("The procedure \"toolPropertyWinSetCommon\" is obsolete.\n");        
  26.     print ("Please use \"toolPropertySetCommon\" instead.\n");        
  27.     error ("Obsolete procedure");        
  28. }
  29.  
  30. // Set up the common properties needed for all tools
  31. // This is : name, icon, help doc
  32. //
  33. global proc toolPropertySetCommon(string $name, string $icon, string $help) 
  34. {
  35.     // If we are displaying the icon, set it for the tool
  36.     //
  37.     string $image = `toolPropertyWindow -query -icon`;
  38.     if ($image != "") picture -edit -image $icon $image;
  39.  
  40.     string $nameField = `toolPropertyWindow -query -field`;
  41.     string $reset = `toolPropertyWindow -query -resetButton`;
  42.     string $helpButton = `toolPropertyWindow -query -helpButton`;
  43.  
  44.     if ($help != "") {
  45.         string $cmd = "showHelp "+$help;
  46.         button -edit -enable true -command $cmd $helpButton;
  47.     } else {
  48.         button -edit -enable false $helpButton;
  49.     }
  50.  
  51.     string $toolCtxName;
  52.     if ( `contextInfo -exists $name` ){
  53.         $toolCtxName = `contextInfo -t $name`;
  54.         button -edit -enable true $reset;
  55.     } else {
  56.         $toolCtxName = "Channel Box Manipulator";
  57.         button -edit -enable false $reset;
  58.     }
  59.     text -edit -label $toolCtxName $nameField;
  60.     button -edit -command ("resetTool " + $name) $reset;
  61. }
  62.  
  63.  
  64. global proc toolPropertyShow() {
  65.     if (`window -exists toolProperties`) {
  66.         //
  67.         //    Bug fix #145854. Calling the "showWindow" command on NT
  68.         //    has the effect of giving that window focus. Consequently,
  69.         //    that takes keyboard focus away from the main Maya window
  70.         //    and hotkeys are no longer active.
  71.         //
  72.         //    Don't want to call showWindow on Irix either because it
  73.         //    has the annoying behaviour of popping the window to the
  74.         //    front.
  75.         //
  76.         if (!`window -query -visible toolProperties`) {
  77.             showWindow toolProperties;
  78.         }
  79.     }
  80. }
  81.  
  82. global proc toolPropertySelect(string $whichPropSheet) {
  83.     string $parent = `toolPropertyWindow -query -location`;
  84.     setParent $parent;
  85.     tabLayout -edit -selectTab $whichPropSheet $parent;
  86.     toolPropertyShow();
  87. }
  88.  
  89. proc createToolSettingsWindow() 
  90. {
  91.     global string $gToolSettingsSeparateWindowLocation;
  92.     global string $gToolSettingsSeparateWindowIcon;
  93.     global string $gToolSettingsSeparateWindowName;
  94.     global string $gToolSettingsSeparateWindowResetButton;
  95.     global string $gToolSettingsSeparateWindowHelpButton;
  96.  
  97.       string $window = `window
  98.         -title "Tool Settings"
  99.         -iconName "Tools"
  100.         -width 428
  101.         -height 500
  102.         toolProperties`;
  103.  
  104.           string $form = `formLayout toolProperties_C`;
  105.  
  106.             string $imageAndNameForm = `formLayout`;
  107.  
  108.             string $image = `picture -image "vacantCell.xpm" toolSmallIcon`;
  109.             string $name = `text -label "" -align "left"`;
  110.  
  111.         setParent ..;
  112.  
  113.         formLayout -edit 
  114.             -attachForm        $image    "top"     1
  115.             -attachForm        $image    "left"    2
  116.             -attachNone        $image    "bottom"
  117.             -attachNone        $image    "right"
  118.  
  119.             -attachForm        $name    "top"    10
  120.             -attachControl    $name    "left"    5 $image
  121.             -attachNone        $name    "bottom"
  122.             -attachNone        $name    "right"
  123.  
  124.             $imageAndNameForm;
  125.  
  126.         // Add this in so we can load in help icons when required
  127.         //
  128.           columnLayout helpIconArea;
  129.         setParent ..;
  130.  
  131.           string $targetName = `tabLayout
  132.             -scrollable        true
  133.             -tabsVisible       false
  134.             -innerMarginWidth  5
  135.             -innerMarginHeight 5
  136.             context_T`;
  137.         setParent ..;
  138.  
  139.         string $reset = `button -label "Reset Tool"`;
  140.         string $help = `button -label "Tool Help..."`;
  141.         string $close = `button -label "Close"
  142.             -command ("deleteUI toolProperties")`;
  143.  
  144.         formLayout -e
  145.             -attachForm     $imageAndNameForm "top"    0
  146.             -attachForm     $imageAndNameForm "left"   0
  147.             -attachForm     $imageAndNameForm "right"  0
  148.  
  149.             -attachControl  helpIconArea    "top"    0 $imageAndNameForm
  150.             -attachForm     helpIconArea    "left"   0
  151.             -attachForm     helpIconArea    "right"  0
  152.  
  153.             -attachControl  $targetName     "top"    0 helpIconArea
  154.             -attachForm     $targetName     "left"   0
  155.             -attachForm     $targetName     "right"  0
  156.             -attachControl  $targetName     "bottom" 2 $close
  157.  
  158.             -attachNone        $reset          "top"  
  159.             -attachForm        $reset          "left"     2
  160.             -attachForm        $reset          "bottom" 2
  161.             -attachPosition    $reset          "right"  1 33 
  162.  
  163.             -attachNone        $help            "top"  
  164.             -attachPosition    $help            "left"     1 33
  165.             -attachForm        $help            "bottom" 2
  166.             -attachPosition    $help            "right"  1 66
  167.  
  168.             -attachPosition    $close            "left"   1 66
  169.             -attachForm     $close          "bottom" 2
  170.             -attachForm     $close          "right"  2
  171.             -attachNone     $close          "top"
  172.             $form;
  173.     setParent ..;
  174.         
  175.     $gToolSettingsSeparateWindowLocation    = $targetName;
  176.     $gToolSettingsSeparateWindowIcon        = $image;
  177.     $gToolSettingsSeparateWindowName        = $name;
  178.     $gToolSettingsSeparateWindowResetButton = $reset;
  179.     $gToolSettingsSeparateWindowHelpButton  = $help;
  180.  
  181.     redirectToolSettings("Separate Window");
  182. }
  183.  
  184. proc showToolProperties(string $location)
  185. //
  186. //    Description:
  187. //        Show the tool properties in the specified location.
  188. //
  189. //    Arguments:
  190. //        $location - Either "Main Window" or "Separate Window".
  191. //
  192. {
  193.     //    This is the name of the window containing the Tool Settings.
  194.     //
  195.     string $toolPropertiesWindow = "toolProperties";
  196.  
  197.     //    Determine if the Tool Settings are currently displayed in
  198.     //    a separate window.
  199.     //
  200.     int $windowVisible = false;
  201.     if (`window -exists toolProperties`) {
  202.         $windowVisible = `window -query -visible toolProperties`;
  203.     }
  204.  
  205.     //    Determine if the Tool Settings are currently displayed in the
  206.     //    main Maya window.
  207.     //
  208.     int $componentVisible = `isUIComponentVisible("Tool Settings")`;
  209.  
  210.     if ("Separate Window" == $location) {
  211.  
  212.         if ($windowVisible) {
  213.             //
  214.             //    Tool Settings are already in a separate window.
  215.             //
  216.             //    Make sure the window is visible.
  217.             //
  218.             showWindow $toolPropertiesWindow;
  219.  
  220.         } else {
  221.             //
  222.             //    Hide the Tool Settings component.
  223.             //
  224.             if ($componentVisible) {
  225.                 toggleUIComponentVisibility("Tool Settings");
  226.             }
  227.  
  228.             //
  229.             //    Delete contents of Tool Settings component if necessary.
  230.             //
  231.             //    Don't actually delete all the Tool Settings component contents.
  232.             //    Just delete all the children of the tab layout save for one.
  233.             //
  234.             global string $gToolSettingsForm;
  235.  
  236.             string $childArray[] = `layout -query -childArray $gToolSettingsForm`;
  237.             int    $index;
  238.  
  239.             for ($child in $childArray) {
  240.                 if ("tabLayout" == `objectTypeUI $child`) {
  241.                     $childArray = `tabLayout -query -childArray $child`;
  242.                     for ($index = 1; $index < size($childArray); $index++) {
  243.                         deleteUI $childArray[$index];
  244.                     }
  245.                     break;
  246.                 }
  247.             }
  248.  
  249.             //    Create the Tool Settings window.
  250.             //
  251.             createToolSettingsWindow();
  252.         }
  253.  
  254.     } else if ("Main Window" == $location) {
  255.  
  256.         if ($windowVisible) {
  257.             //
  258.             //    Delete the Tool Settings window.
  259.             //
  260.             deleteUI -window $toolPropertiesWindow;
  261.  
  262.             //    Create the Tool Settings component contents.
  263.             //
  264.  
  265.             //    Show the Tool Settings component.
  266.             //
  267.             if (!$componentVisible) {
  268.                 toggleUIComponentVisibility("Tool Settings");
  269.             }
  270.  
  271.         } else if ($componentVisible) {
  272.             //
  273.             //    Tool Settings component is already visible.
  274.             //
  275.  
  276.         } else {
  277.             //
  278.             //    Delete the Tool Settings window if necessary.
  279.             //
  280.             if (`window -exists toolProperties`) {
  281.                 deleteUI -window $toolPropertiesWindow;
  282.             }
  283.  
  284.             //    Create the Tool Settings component conetents if necessary.
  285.             //
  286.  
  287.             //    Show the Tool Settings component.
  288.             //
  289.             toggleUIComponentVisibility("Tool Settings");
  290.         }
  291.  
  292.     } else {
  293.         //
  294.         //    Nothing to do here because the Tool Settings are visible in
  295.         //    either a window or the component.
  296.         //
  297.     }
  298. }
  299.  
  300. global proc toolPropertyWindow1(string $location) {
  301.  
  302.     if ("" == $location) {
  303.         //
  304.         //    Determine if the Tool Settings are currently displayed in
  305.         //    a separate window.
  306.         //
  307.         int $windowVisible = false;
  308.         if (`window -exists toolProperties`) {
  309.             $windowVisible = `window -query -visible toolProperties`;
  310.         }
  311.  
  312.         //    Determine if the Tool Settings are currently displayed in the
  313.         //    main Maya window.
  314.         //
  315.         int $componentVisible = `isUIComponentVisible("Tool Settings")`;
  316.  
  317.         if ($windowVisible) {
  318.             //
  319.             //    Window is up so use that location.
  320.             //
  321.             $location = "Separate Window";
  322.  
  323.         } else if ($componentVisible) {
  324.             //
  325.             //    Component is up so use that location.
  326.             //
  327.             $location = "Main Window";
  328.  
  329.         } else {
  330.             //
  331.             //    Use the user's preferred location.
  332.             //
  333.             if (`optionVar -query toolSettingsInMainWindow`) {
  334.                 $location = "Main Window";
  335.             } else {
  336.                 $location = "Separate Window";
  337.             }
  338.         }
  339.     }
  340.  
  341.     showToolProperties($location);
  342. }
  343.